A5.msgBox.show Method
Syntax
Arguments
- titlestring
The title HTML text to display on the message box.
- htmlstring
The HTML to display in the body of the message box.
- typestring
A flag to tell the message box what buttons to display. The values for this flag are:
- Value
- Description
- "o"
"OK" button.
- "oc"
"OK" and "Cancel" buttons.
- "yn"
"Yes" and "No" buttons.
- "ync"
"Yes", "No" and "Cancel" buttons.
- "none"
No buttons.
- onClosefunction
A Javascript function that will be called when the user closes the message box. This function will be passed a string containing the value of the button the user pressed ("ok", "yes", "no", or "cancel").
Description
Displays a message box.
Discussion
This function can be used to display a message box in the HTML that is done entirely in JavaScript and HTML meaning that you can present the user with a customized HTML message.
Example
This example shows how to create a message box with an Yes, No, and Cancel button. This message is shown when the user attempts to close a window before saving their work. The onClose function will handle saving or closing without saving when the user clicks a button. In this example, if the user clicks the "yes" button, a Javascript Action will be run to save their work and close the window. If the user clicks "no", a Javascript Action is run to close the window without saving. If the user clicks "cancel" or closes the window without making a choice, the action is cancelled.
var title = 'Save Before Closing?';
var html = '<p>Do you wish to save your work before closing the window?</p>';
var type = 'ync';
var onClose = function (btn) {
if (btn == 'yes') {
// save their work then close the window
{dialog.object}.runAction("saveAndClose");
} else if (btn == 'no') {
// close the window
{dialog.object}.runAction("close");
} else {
// cancel - do nothing
}
};
A5.msgBox.show(title, html, type, onClose);Example: Customizing HTML Buttons
You can set properties to control the text and class of the OK and Cancel buttons. Example:
A5.msgBox.buttons.ok = {html: 'My OK HTML', className: 'MyOKButtonClassName'};
A5.msgBox.buttons.cancel = {html: 'My Cancel HTML', className: 'MyCancelButtonClassName'};
A5.msgBox.buttons.ok = {html: 'My OK HTML', className: 'MyOKButtonClassName'};
A5.msgBox.buttons.cancel = {html: 'My Cancel HTML', className: 'MyCancelButtonClassName'};See Also